package dm71.espil.activities;

import dm71.espil.AccelerometerListener;
import dm71.espil.AccelerometerManager;
import dm71.espil.R;
import android.app.Activity;
import android.graphics.Color;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.util.Log;
import android.view.View.OnCreateContextMenuListener;
import android.widget.TextView;
import android.widget.Toast;

/**
 * TODO Put here a description of what this class does.
 * 
 * @author Moulde. Created Dec 20, 2011.
 */
public class AccelerometerPrototypeActivity extends Activity implements
		AccelerometerListener
{
	TextView txtX;
	TextView txtY;
	TextView txtZ;

	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.accelerometerprototype);

		txtX = (TextView) findViewById(R.id.txtX);
		txtY = (TextView) findViewById(R.id.txtY);
		txtZ = (TextView) findViewById(R.id.txtZ);
		
		AccelerometerManager.SetContext(this);
		AccelerometerManager.StartListening(this);
	}

	public void onAccelerationChanged(float x, float y, float z)
	{
		txtX.setText(String.valueOf(x));
		txtY.setText(String.valueOf(y));
		txtZ.setText(String.valueOf(z));
	}

	public void onShake(float force)
	{
		Toast.makeText(this, "SHAKE: " + force, 1000).show();
	}
}
